<!-- /* Description for file.
 * 用户管理-修改
 *
 * @copyright     Copyright 2008-2010, PHInfo Services Inc. (http://www.phinfoservices.com)
 * @package       ues
 * @subpackage    ues/app/views/users
 * @since         ues
 * @version       V0.0.1
 * @modifiedby    
 * @lastmodified  张海杰2011年0717
 */-->
 
<?php
echo $html->css ( 'tab' );
echo $html->css ( 'style' );
echo $javascript->link('jquery-1.4.2');
echo $html->css('start/jquery-ui-1.8.2.custom');
echo $javascript->link('jquery-ui-1.8.2.custom.min');
echo $html->css ( 'jquery-validate/css/screen' );
echo $javascript->link ( 'jquery-validate/jquery.validate');
echo $javascript->link ( 'jquery-validate/additional-methods');
echo $javascript->link ( 'jquery-validate/localization/messages_cn');

?>
 <script type="text/javascript">
	$(function()
	{
		$("#close").click(function(){		
			window.close();							
		});
		$("#organ").change(function(){
			var company = $(this).val();
			if(company!="")
			{
				$.post("<?php echo ROOT_WEB_PATH; ?>/visitorlists/getdepartments/",{
					Organ : $(this).val()
					},function(data,textStatus){
						 $("#department:eq(0)>option").remove();
						 $(data).find("aaa").each(function(){
						 $("#department:eq(0)").append("<option></option>");
						 if($(this).text()=="")
						 {
							 $("#department:eq(0)>option:last").val("").html($(this).text());
						 }
						 else
						 {
							 $("#department:eq(0)>option:last").val($(this).attr('name')).html($(this).text());
						 }
					  });
					});
			}
			else
			{
				$("#department:eq(0)>option").remove();
				$("#department:eq(0)").append("<option></option>");
				$("#department:eq(0)>option:last").val("").html("");
			}
		});
	});
	//添加验证
	$(document).ready(function() {
		$.validator.setDefaults({       
			 submitHandler: function(form) {    
			  form.submit();    
			}       
		});   

		$("#UserEditForm").validate({
	rules: {
	"data[User][username]"  :{
	required: true,string:true,stringMinLength:1,stringMaxLength:20
	},//
	"data[User][password]"  :{
	required: true,password:true
	},//
	"data[User][department_id]"   :{
	required: true,selectNone:true
	},//
	"data[User][organs]"  :{
	required: true,selectNone:true 
	},//
	"data[User][name]"  :{
	required: true,alowsome:true,stringMinLength:1,stringMaxLength:50
	},//
	"data[User][tel]"  :{
	required: false,phone:true
	},//
	"data[User][mobilePhone]"  :{
	required: false,mobile:true
	},//
	"data[User][otherMessage]"  :{
	required: false
	},// 
	"data[User][email]" :{
	required: false,email:true
	} 
			},
			focusInvalid:false,
			onkeyup:false,
			errorPlacement:function(error, element){error.appendTo(element.parent());}
		});
	});
	//验证结束
</script>
<?php
	//机构选项
	$optionsOrgan = array();
	foreach($organs as $organ)
	{
		$optionsOrgan[$organ['Organ']['id']] = $organ['Organ']['name'];
	}
	//部门选项
	$optionsDepartment = array();
	foreach($departments as $department)
	{
		$optionsDepartment[$department['Department']['id']] = $department['Department']['name'];
	}
	//组选择
	$optionsGroup = array();
	foreach($groups as $group)
	{
		$optionsGroup[$group['Group']['id']] = $group['Group']['name'];
	}
?>
<!-- 当前位置-->
<div id="tabmenubar">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="tabmenubartitle1"><?php echo  __('YourPosition');//您现在的位置：?></td>
		<td class="tabmenubartitle2"><?php echo __('Usersmanagements');//一级目录
										   echo '>';echo __('Usersmanagements');//二级目录
										   echo '>';?>
									<?php echo $html->tag('span', __('Edit User',true));//当前操作地用span加粗?> 						  
		</td>
	</tr>
</table>
</div>
<!-- 当前位置-->
<div class="tabflex">
<?php echo $form->create('User',array('action'=>'edit','type'=> 'post'));?>
		<?php echo $form->input('id', array('default'=>$user['User']['id']));?>	
 <fieldset>
	<legend><?php  __('Edit User');?></legend>
	<table width="100%" cellspacing="0" cellpadding="0" border="0" style="text-align: left">
		<tr>
		<td width="5%"></td>
		<td width="10%"><?php __('groupSelector');//类别?>:<font color="red">*</font></td>
		<td  width="25%"><?php 
			echo $form->input('group_id',array('options'=>$optionsGroup,'default'=>$user['User']['group_id'],'label'=>false,'div'=>false,'class'=>'TextBoxE1'));
			?>
		</td>

		<td width="10%"><?php __('Group');//机构?>:<font color="red">*</font></td>
		<td  width="25%">
			<?php 
			echo $form->input('organ',array('options'=>$optionsOrgan,'id'=>'organ','default'=>$user['User']['organ_id'],'label'=>false,'div'=>false,'class'=>'TextBoxE1'));	
			?>
		</td>

		<td width="10%"><?php __('Departments');//部门?>:<font color="red">*</font></td>
		<td  width="20%"><?php 
			echo $form->input('department_id',array('options'=>$optionsDepartment,'id'=>'department','default'=>$user['User']['department_id'],'label'=>false,'div'=>false,'class'=>'TextBoxE1'));
			?>
		</td>

	</tr>
	<tr>
		<td></td>
		<td><?php __('Username');//用户名?>:<font color="red">*</font></td>
		<td>
			<?php 
			echo $form->input('username',array('default'=>$user['User']['username'],'class' => 'TextBoxE1','label'=>false));	
			?>
		</td>

		<td><?php __('Password');//密码?>:<font color="red">*</font></td>
		<td><?php 
			echo $form->input('password',array('default'=>$user['User']['password'],'class' => 'TextBoxE1','label'=>false));
			?>
		</td>

		<td><?php __('resumesname');//姓名?>:<font color="red">*</font></td>
		<td>
			<?php 
			echo $form->input('name',array('default'=>$user['User']['name'],'class' => 'TextBoxE1','label'=>false));
			?>
		</td>

	</tr>
	<tr>
		<td></td>
		<td><?php __('sex');//性别?>:</td>
		<td><?php 
			echo $form->input('sex',array('options'=>array('0'=>'保密','1'=>'男','2'=>'女'),'label'=>false,'default'=>$user['User']['sex']));
			?>
		</td>
		<td><?php __('telephone');//电话?>:</td>
		<td>
			<?php 
			echo $form->input('tel',array('default'=>$user['User']['tel'],'class' => 'TextBoxE1','label'=>false));
			?>
		</td>
		<td><?php __('mobilePhone');//手机?>:</td>
		<td>
			<?php 
			echo $form->input('mobilePhone',array('default'=>$user['User']['mobilePhone'],'class' => 'TextBoxE1','label'=>false));
			?>
		</td>
		<td></td>
	</tr>
	<tr>
		<td></td>
		<td><?php __('birthday');//生日?>:</td>
		<td>
			<?php 
//			if(empty($user['User']['birthday']))$selectedDay = null;
//			else
//				$selectedDay = "";
			echo $form->input('birthday',array('type'=>'date','minYear'=>'1950','maxYear'=>'2010','dateFormat'=>'YMD','monthNames' => false,'selected'=> $user['User']['birthday'],'empty'=>'不填','label'=>false));
			?>
		</td>
		<td><?php __('email');//邮箱?>:</td>
		<td>
			<?php 
			echo $form->input('email',array('default'=>$user['User']['email'],'class' => 'TextBoxE1','label'=>false));
			?>
		</td>
		<td colspan="4"></td>
	</tr>
	<tr>
		<td></td>
		<td><?php __('otherMessage');//备注?>:</td>
		<td colspan="8">
			<?php 
			echo $form->textarea('otherMessage',array('default'=>$user['User']['otherMessage'],'class' => 'areaStyle','label'=>false));
			?>
		</td>
	</tr>
	</table>
	</fieldset>
	<table width="100%" cellspacing="0" cellpadding="0" border="0" style="text-align: left">
	<tr>
		<td width="50"></td>
		<td width="100"><?php echo $form->button('确定',array('type'=>'submit','class'=>'oksubmit'));?>
		<td width="100"><?php echo $form->button('重置',array('type'=>'reset','class'=>'resetsubmit'));?>
		<td width="100"><?php echo $form->button('关闭',array('class'=>'cancelbutton','id'=>'close'));?>
		</td>
	</tr>
	</table>
<?php echo $form->end();?>
</div>